
package com.documents.main.action;

import com.documents.common.core.action.BaseActionSupport;
import com.documents.common.util.RandomNumUtil;
import java.io.ByteArrayInputStream;
import org.apache.struts2.interceptor.ServletRequestAware;


public class RandomAction extends BaseActionSupport implements ServletRequestAware {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final String VALIDATEFLAG = "random";
	private ByteArrayInputStream inputStream;

	public String execute() throws Exception {
		RandomNumUtil rdnu = RandomNumUtil.Instance();
		this.setInputStream(rdnu.getImage());// 取得带有随机字符串的图片
		getRequest().getSession().setAttribute(VALIDATEFLAG, rdnu.getString());// 取得随机字符串放入HttpSession
		return SUCCESS;
	}

	public ByteArrayInputStream getInputStream() {
		return inputStream;
	}

	public void setInputStream(ByteArrayInputStream inputStream) {
		this.inputStream = inputStream;
	}
}